package eg.backend.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.datanucleus.jpa.annotations.Extension;

@Entity
@NamedQueries({
	@NamedQuery(name = "Budget.getByTag", query = "select t from Budget t where t.owner = :user and t.tag = :tag and t.begin = :from and t.end = :to"),
	@NamedQuery(name = "Budget.findByCategories", query = "select t from Budget t where t.owner = :user" +
			" and t.category in (:categories) and t.begin = :from and t.end = :to")
})
public class Budget {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String encodedKey;

	private String owner;
	
	private float amount;
	@Temporal(TemporalType.DATE)
	private Date begin;
	@Temporal(TemporalType.DATE)
	private Date end;
	
	private String category;
	private String tag;

	private Set<String> goals = new HashSet<String>();
	
	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getCategory() {
		return category;
	}

	public float getAmount() {
		return amount;
	}

	public void setAmount(float amount) {
		this.amount = amount;
	}

	public Date getBegin() {
		return begin;
	}

	public void setBegin(Date begin) {
		this.begin = begin;
	}

	public Date getEnd() {
		return end;
	}

	public void setEnd(Date end) {
		this.end = end;
	}
	
	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public String getEncodedKey() {
		return encodedKey;
	}

	public void setEncodedKey(String encodedKey) {
		this.encodedKey = encodedKey;
	}

	public Set<String> getGoals() {
		return goals;
	}

	public void setGoals(Set<String> goals) {
		this.goals = goals;
	}

}
